#ifndef PICVIEWER_H
#define PICVIEWER_H

#include <qwidget.h>
#include <qstring.h>
#include <qevent.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qdir.h>
#include <qtimer.h>
#include <qvbox.h>
#include <qhbox.h>
#include <ZMainWidget.h>
#include <ZScrollView.h>

class ZLabel;
class PicViewer : public QWidget
{
    Q_OBJECT
    
public:
    PicViewer(const QString& pic,QWidget *parent=0);//, const char *name=0 ,WFlags f=0);//
    ~PicViewer();
    void showImage(QString fileName);
    void loadImage(const QString &filename);
	void track(bool trackEnabled);
	void gestrue();
	void showGif(const QString &gif);
	QString getPicName() {return m_cFileName;}
	int getMag() {return m_fFactor*100;}
signals:
	void zooming(int magnification);
	
public slots:
    void info();
    void zoomIn ();
    void zoomOut();
    void zoomNormal(void);
    void zoomFit(void);
    void showNext(bool updateList);
    void showPrev(bool updateList);
	void rotate(int degree);
	void syncZoom();
	//void edit();
	void setTrack();

	
protected:
    virtual void paintEvent( QPaintEvent* );
    virtual void mousePressEvent ( QMouseEvent * event );
    virtual void mouseMoveEvent ( QMouseEvent * event );
    virtual void mouseReleaseEvent ( QMouseEvent * event );
	virtual void mouseDoubleClickEvent ( QMouseEvent * event );
    void loadImageFaild(void);
	//void loadingImage(void);


private:
	ZLabel *label;
	int idTrack;
	QTimer	*timer;
	QString imgFilter, preDir;
	QString m_cFileName;            //deletes
	QPixmap* m_pImage;
    QPoint  m_cCenPos;
    QPoint  m_cStartPos;
	QDir m_cDirCur;
	QStringList m_cDisFiles;
	QStringList::ConstIterator m_cCurFile;
    float   m_fFactor, mag;
    float   m_fFitFactor;
	int x1, y1, x2, y2;
	int rotation;
	bool trackEnabled, dclick;
	//ZScrollView* sv;  //subclass holds mouse events
};

class ZLabel : public QLabel
{
   	Q_OBJECT
public:
	ZLabel(QWidget *parent = 0, char const *name = 0, WFlags f = 0);
	//void mouseReleaseEvent(QMouseEvent *);
//public slots:
   // virtual void setText( const QString &);
   QPoint pos1;
   //enum {}
   bool moveMode;
   int w,h;
   void Resize(int x,int y);
   
signals:
	void clicked();
	//void resized();
protected:
	virtual void mousePressEvent(QMouseEvent *);
	void mouseMoveEvent( QMouseEvent *e );
	void mouseDoubleClickEvent( QMouseEvent *);
};


#endif //PICVIEWER_H
